package zkk.com.mengqu.adapter;

import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import zkk.com.mengqu.R;
import zkk.com.mengqu.activity.PrivateFoodActivity;

/**
 * 私人菜谱页面适配器
 */
public class PrivateMenuAdapter extends BaseAdapter {
    private Context context;

    public PrivateMenuAdapter(Context context) {
        this.context = context;
    }

    @Override
    public int getCount() {
        return 10;
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {

        HomeHolder homeHolder;
        if(convertView==null){
            homeHolder=new HomeHolder();
            convertView= LayoutInflater.from(context).inflate(R.layout.item_private_menu,null);

            convertView.setTag(homeHolder);
        }else{
            homeHolder=(HomeHolder)convertView.getTag();
        }

        convertView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                context.startActivity(new Intent(context , PrivateFoodActivity.class));
            }
        });

        return convertView;
    }

    class HomeHolder{
        ImageView iv_tagImg;
        TextView tv_tagName;
    }
}